#ifndef MAPSCENE_H
#define MAPSCENE_H

#include "Scene.h"
#include "vector"
#include "Collision.h"
#include "Map.h"
#include "ObBackground.h"
#include <sstream>
#include <fstream>
#include <iostream>
#include "cstdio"

class MapScene : public Scene{
public:
	MapScene(std::string filename, std::string mapname);
	~MapScene();

	bool loading();
	SceneRS update(float dt);
	void draw(ID3DXSprite* sprite);
	void drawTransparentGround(ID3DXSprite* sprite);
	void drawInfo(ID3DXSprite* sprite);
	void loadTexture();
	void releaseTexture();
	void setSetting(int life, int score, int state);

	void saveMap();
	void writeOut(TreeNode* node);

	void onLostDevice();
	void onResetDevice();

	vector<ObObject*> mNewObject;
	Map* mMap;
protected:
	vector<ObObject*> mActiveObject;
	vector<ObObject*> mBackObject;

	ID3DXFont* mFont;
	
	bool isLoading;
	std::string mMapName;
	std::string mFileName;
	vector<int> needLoadBack;
	vector<int> needLoadChosed;
	ObBackGround* mBackground;
	int mTime;
	int mLife;
	int mScore;
	float count;
	float timePass;
	bool canPause;

	IDirect3DTexture9* mBackTex;
	D3DXVECTOR3 mTransparentGroundPos;
	D3DXVECTOR3 mTransparentGroundCenter;

	std::ofstream outfile;
};

extern MapScene* gMapScene;

#endif